home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / NDK / NDK_3.5 / Examples / Workbench / SelectIcon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-30  |  1.7 KB  |  82 lines

  1. /*
  2.  * $Id$
  3.  *
  4.  * :ts=4
  5.  *
  6.  * COPYRIGHT:
  7.  *
  8.  *   Unless otherwise noted, all files are Copyright (c) 1999 Amiga, Inc.
  9.  *   All rights reserved.
  10.  *
  11.  * DISCLAIMER:
  12.  *
  13.  *   This software is provided "as is". No representations or warranties
  14.  *   are made with respect to the accuracy, reliability, performance,
  15.  *   currentness, or operation of this software, and all use is at your
  16.  *   own risk. Neither Amiga nor the authors assume any responsibility
  17.  *   or liability whatsoever with respect to your use of this software.
  18.  *
  19.  */
  20.  
  21. #include <workbench/workbench.h>
  22.  
  23. #include <exec/libraries.h>
  24.  
  25. #include <utility/hooks.h>
  26.  
  27. #include <clib/utility_protos.h>
  28. #include <clib/dos_protos.h>
  29. #include <clib/wb_protos.h>
  30.  
  31. #include <pragmas/utility_pragmas.h>
  32. #include <pragmas/dos_pragmas.h>
  33. #include <pragmas/wb_pragmas.h>
  34.  
  35. #include <string.h>
  36.  
  37. /****************************************************************************/
  38.  
  39. extern struct Library * WorkbenchBase;
  40. extern struct Library * UtilityBase;
  41. extern struct Library * DOSBase;
  42.  
  43. /****************************************************************************/
  44.  
  45. ULONG __saveds __asm
  46. HookFunc(
  47.     register __a0 struct Hook * hook,
  48.     register __a2 APTR reserved,
  49.     register __a1 struct IconSelectMsg * ism)
  50. {
  51.     STRPTR name = hook->h_Data;
  52.     ULONG result = ISMACTION_Ignore;
  53.  
  54.     if(Stricmp(name,ism->ism_Name) == 0)
  55.         result = ISMACTION_Select;
  56.  
  57.     return(result);
  58. }
  59.  
  60. /****************************************************************************/
  61.  
  62. int
  63. main(int argc,char **argv)
  64. {
  65.     if(WorkbenchBase->lib_Version >= 44)
  66.     {
  67.         if(argc > 2)
  68.         {
  69.             struct Hook hook;
  70.  
  71.             memset(&hook,0,sizeof(hook));
  72.  
  73.             hook.h_Entry = (HOOKFUNC)HookFunc;
  74.             hook.h_Data = argv[2];
  75.  
  76.             ChangeWorkbenchSelectionA(argv[1],&hook,NULL);
  77.         }
  78.     }
  79.  
  80.     return(0);
  81. }
  82.